<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品游戏后台管理</title>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <style>
        th{
            text-align: center;
            vertical-align: middle!important;
        }
    </style>
</head>
<body>
{include file="base/header" /}
<table class="layui-table">
    <thead>
    <tr>
        <th>编号</th>
        <th>商品名称</th>
        <th>商家联系人</th>
        <th>购买数量(个)</th>
        <th>进价(元)</th>
        <th>售价(元)</th>
        <th>总价(元)</th>
        <th>实际总价(元)</th>
        <th>下单时间</th>
        <th>订单号</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {foreach $result as $val}
        <tr id="del{$val.id}">
            <td>{$val.id}</td>
            <td>{$val.pname}</td>
            <td>{$val.linkman}</td>
            <td>{$val.number}</td>
            <td>{$val.purchaseprice}</td>
            <td>{$val.retailprice}</td>
            <td>{$val.total}</td>
            <td>{$val.actualtotal}</td>
            <td>{$val.date}</td>
            <td>{$val.ordernumber}</td>
            <td>{if $val.status == 1} 购买申请 {elseif $val.status == 2/} 购买通过 {elseif $val.status == 3/}邮寄中{elseif $val.status == 4/}货已到{else/}已完成{/if}</td>
            <td>
                <button onclick="del({$val.id})" type="button" class="btn btn-danger btn-xs">删除</button>
                <button onclick="orderDetail({$bid},{$val.id})" type="button" class="btn btn-primary btn-xs" >订单详情</button>
                <!--{if $val.status == 5}-->
                    <!--<button onclick="playmoney({$val.id})" type="button" class="btn btn-warning btn-xs" >打款</button>-->
                <!--{else/}-->
                    <!--<button disabled type="button" class="btn btn-warning btn-xs" >打款</button>-->
                <!--{/if}-->
            </td>
        </tr>
    {/foreach}
    </tbody>
</table>
</body>
<script>
    //删除
    function del(id) {
        layer.confirm('你确定要删除吗',{bnt:['确定','取消']},
            function () {
                $.ajax({
                   url:"{:url('index/postsettlement/delete')}",
                   data:"id="+id,
                   type:"post",
                   dataType:"json",
                   success:function (res) {
                        if(res.success){
                            layer.alert(res.success);
                            $("#del"+id).remove();
                        }
                        if(res.error){
                            layer.alert(res.error);
                        }
                   }
                });
            }
        );
    }
    //订单详情
    function orderDetail(bid,id) {
        window.location.href = "{:url('index/postsettlement/orderDetail')}?id="+id+"&bid="+bid;
    }
    //打款
    function playmoney(id) {
        layer.open({
            title:'上传支付凭证',
            anim: 2,
            type: 2,
            content: "{:url('index/postsettlement/image')}?id="+id,
            area: ['320px', '195px']
        });
    }
</script>
</html>